﻿using System;
using System.Collections.Generic;
using System.Text;
using FunctionalCLR.Core;

namespace FunctionalCLR.Core.Function.List {

    /// <summary>
    /// lst = [1,2,3,4,5];
    /// length = length(lst);
    /// echo(length);
    /// </summary>
    public class ListLengthNode : FuncNode {

        public ListLengthNode()
            : base() {
            this.Value = "count";
        }

        public override FuncNode GetReversedFunction(int index) {
            throw new NotImplementedException();
        }

        public override object Evaluate() {
            if (!Children[0].GetType().Equals(typeof(ListNode))) {
                throw new Exception();
            }

            return Children.Count;
        }
    }
}
